package com.topInterview;

/**
 * @Author: huangzhigao
 * @Date: 2022/2/13 14:38
 */
public class Leetcode11_WaterMaxArea {
    public int maxArea(int[] height) {
        int left = 0;
        int right = height.length - 1;
        int res = 0;
        while (left < right) {
            res = Math.max(res, Math.min(height[left], height[right]) * (right - left));
            if (height[left] < height[right]) {
                left++;
            } else {
                right--;
            }
        }

        return res;
    }
}
